<template>
  <div class="common-search-form-component">
    <a-form :model="queryParams">
      <a-row :gutter="16">
        <a-col :xs="24" :sm="12" :md="12" :lg="6" :xl="6">
          <a-form-item name="keyword" :label="$t('menu.name')">
            <a-input
              v-model:value="queryParams.keyword"
              :placeholder="$t('menu.searchPlaceholder')"
              allow-clear
              @pressEnter="handleSearch"
            />
          </a-form-item>
        </a-col>
        
        <a-col :xs="24" :sm="12" :md="12" :lg="6" :xl="6">
          <a-form-item name="status" :label="$t('menu.status')">
            <a-select
              v-model:value="queryParams.status"
              :placeholder="$t('menu.statusPlaceholder')"
              :options="statusOptions"
              allow-clear
            />
          </a-form-item>
        </a-col>
      </a-row>
    </a-form>
  </div>
</template>

<script lang="ts" setup>
import type { MenuQuery } from '@/types/api/system/menu'
import { useI18n } from 'vue-i18n'

// 组件名称
defineOptions({
  name: 'MenuSearchForm'
})

// 国际化
const { t } = useI18n()

// 组件属性
withDefaults(defineProps<{
  queryParams: MenuQuery
}>(), {
  queryParams: () => ({
    title: '',
    status: undefined
  }) as MenuQuery
})

// 组件事件
const emit = defineEmits<{
  (e: 'search'): void
}>()

// 状态选项
const statusOptions = [
  { value: 1, label: t('common.enabled') },
  { value: 0, label: t('common.disabled') }
]

/**
 * 搜索处理
 */
const handleSearch = () => {
  emit('search')
}

</script>

<style lang="scss" scoped>
@import '@/assets/styles/views/common.scss';
</style> 